package com.hk.Mgr.web.controller.remoteCall;

import com.hk.Mgr.web.dto.ProductUsableCouponDTO;
import com.hk.base.BaseCtrl;
import com.hk.commons.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Antinomy on 17/3/27.
 */
@Controller
@RequestMapping(value = BaseCtrl.App + "/productCoupon")
public class ProductCouponController {

    @Autowired
    ActivityService activityService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public JsonResult list(String filter,String productId) {
        String url = "api/coupon/productCanUse/list?productId="+productId+"&filter=" + filter;

        JsonResult result = activityService.httpGet(url);
        return result;
    }

    @RequestMapping(value = "/list/{productId}", method = RequestMethod.GET)
    @ResponseBody
    public JsonResult listByProd(@PathVariable Long productId) {
        String url = "api/coupon/productCanUse/list/" + productId;

        JsonResult result = activityService.httpGet(url);
        return result;
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public JsonResult update(@RequestBody ProductUsableCouponDTO dto) {
        String url = "api/coupon/productCanUse/update";

        JsonResult result = activityService.httpPost(url, dto);
        return result;
    }
}
